//
//  mainFabu.m
//  HappyStore
//
//  Created by 点点充 on 16/1/14.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "mainFabu.h"
#import "putDynamicVC.h"
#import "Release_SupplyChain.h"
@interface mainFabu ()
{
    NSString *strType;
}
@end

@implementation mainFabu

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"白色背景"] forBarMetrics:UIBarMetricsDefault];
    //找出导航栏的下边的黑线
    UIImageView *navBarHairlineImageView = [NaviBarLine findHairlineImageViewUnder:self.navigationController.navigationBar];
    navBarHairlineImageView.hidden = NO;

}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发布";
    [self.navigationController.navigationBar setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:19],NSFontAttributeName,RGB(45, 45, 45),NSForegroundColorAttributeName, nil]];
    //设置返回按钮
//    UIBarButtonItem *leftItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftBarButtonItemClick) image:@"返回" highImage:@"返回"];
//    self.navigationItem.leftBarButtonItem = leftItem;
    //隐藏backbutton
    self.navigationItem.hidesBackButton = YES;

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(btnClickGoTo:) name:@"gotoPush" object:nil];
    
    
}

-(void)leftBarButtonItemClick{
    
}

- (void)btnClickGoTo:(NSNotification *)dic
{
    NSDictionary *dicInfoo = dic.userInfo;
    switch ([dicInfoo[@"type"] integerValue]) {
        case 1://项目
        {
            Project_Detail *project_detail = [self.storyboard instantiateViewControllerWithIdentifier:@"project_detail"];
            project_detail.projectId = dicInfoo[@"id"];
            [self.navigationController pushViewController:project_detail animated:YES];
        }
            break;
        case 2://资金
        {
            SearchPrice_Detail *SearchPrice_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchPrice_Detail"];
            SearchPrice_Detail.fundsId = dicInfoo[@"id"];
            [self.navigationController pushViewController:SearchPrice_Detail animated:YES];
        }
            break;
        case 3://活动
        {
            BusinessActivity_Detail *BusinessActivity_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"business_detail"];
            BusinessActivity_Detail.activityId = dicInfoo[@"id"];
            [self.navigationController pushViewController:BusinessActivity_Detail animated:YES];
        }
            break;
        case 4://服务
        {
            SoftwareDevelop_Detail *SoftwareDevelop_Detail = [self.storyboard instantiateViewControllerWithIdentifier:@"SoftwareDevelop_Detail"];
            SoftwareDevelop_Detail.projectId = dicInfoo[@"id"];
            [self.navigationController pushViewController:SoftwareDevelop_Detail animated:YES];
        }
            break;
        case 5://招聘
        {
            Recruitment_Detail *result = [self.storyboard instantiateViewControllerWithIdentifier:@"recruitment_Detail"];
            result.projectId = dicInfoo[@"id"];
            result.strType = @"1";
            [self.navigationController pushViewController:result animated:YES];
        }
            break;
        case 6://求职
        {
            Recruitment_Detail *result = [self.storyboard instantiateViewControllerWithIdentifier:@"recruitment_Detail"];
            result.projectId = dicInfoo[@"id"];
            result.strType = @"2";
            [self.navigationController pushViewController:result animated:YES];
        }
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 发布按钮
- (IBAction)btnClickReleaseAll:(UIButton *)sender
{//取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    
    NSInteger IndexPath = sender.tag - 10;
    switch (IndexPath) {
        case 0://项目pushProject
        {
            [self performSegueWithIdentifier:@"pushProject" sender:self];
        }
            break;
        case 1://供应链
        {

            Release_SupplyChain *supplyChainVC = [[Release_SupplyChain alloc] init];
            [self.navigationController pushViewController:supplyChainVC animated:YES];

        }
            break;
        case 2://商务活动
        {   Release_ActivityChange *actVC = [[Release_ActivityChange alloc] initWithNibName:@"Release_ActivityChange" bundle:nil];
            [self.navigationController pushViewController:actVC animated:YES];
            //[self performSegueWithIdentifier:@"pushActivity" sender:self];
        }
            break;
        case 3://企业服务
        {
            if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 3) {//政府
                [self showSingleIconBubble:@"无操作权限"];

            }else {
                [self performSegueWithIdentifier:@"pushService" sender:self];
            }
        }
            break;
        case 4://资金
        {
//  动态
//            if (allConstMemberid) {
//                
//                putDynamicVC * putDynamic =[[putDynamicVC alloc]init];
//                [self.navigationController pushViewController:putDynamic animated:YES];
//                
//            }else{
//                
//                UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请先登录" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"登录", nil];
//                [alert show];
//                
//            }
            if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 3) {//政府
                [self showSingleIconBubble:@"无操作权限"];
                
            }else {
                [self performSegueWithIdentifier:@"pushPrice" sender:self];
            }
        }
            break;
        case 5://招聘
        {

                strType = @"1";

            Release_Job *jobVC = [[Release_Job alloc] initWithNibName:@"Release_Job" bundle:nil];
            [self.navigationController pushViewController:jobVC animated:YES];
        }
            break;
        case 6://返回
        {
            [self.navigationController popViewControllerAnimated:YES];
        
        }
            break;
            
        default:
            break;
    }
    
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // segue.identifier：获取连线的ID
    if ([segue.identifier isEqualToString:@"pushJobInfo"]) {
        Release_JobInfo *result = segue.destinationViewController;
        result.strTypee = strType;
    }
}




@end
